package xyz.xtt.asset.api.enums;

import java.util.Arrays;
import java.util.Objects;

/**
 * 业务线类型
 * 
 * @author huqibo
 * @date 2025/01/21
 */
public enum BizTypeEnum {
	/**
	 * 聊业务版块
	 */
	LIAO(0, "聊", "liao"),
	/**
	 * 逛业务版块
	 */
	GUANG(1, "逛", "guang"),
	/**
	 * 通业务版块
	 */
	TONG(2, "通", "tong"),
	/**
	 * 看业务版块
	 */
	KAN(3, "看", "kan"),
	/**
	 * 家业务版块
	 */
	JIA(4, "家", "jia"),
	/**
	 * 资产中心业务版块
	 */
	NFT(5, "资产中心", "nft"),

	/**
	 * 探索器
	 */
	EXPLORER(6, "探索器", "explorer"),
	/**
	 * 探索器
	 */
	REDPACKET(7, "红包", "redpacket"),
	/**
	 * 探索器
	 */
	SVIP(7, "会员", "svip"),;
	/**
	 * 编码
	 */
	private int code;
	/**
	 * 描述
	 */
	private String desc;
	private String dbType;

	BizTypeEnum(int code, String desc, String dbType) {
		this.code = code;
		this.desc = desc;
		this.dbType = dbType;
	}

	public int code() {
		return code;
	}

	public String dbType() {
		return dbType;
	}

	public String desc() {
		return desc;
	}

	public static boolean checkType(String checkType) {
		return Arrays.asList(BizTypeEnum.values()).stream().anyMatch(x -> Objects.equals(x.name(), checkType));
	}

	public static BizTypeEnum convert(String checkType) {
		return Arrays.asList(BizTypeEnum.values()).stream().filter(x -> Objects.equals(x.name(), checkType)).findFirst().orElse(null);
	}

	public static BizTypeEnum queryConvert(String dbType) {
		return Arrays.asList(BizTypeEnum.values()).stream().filter(x -> Objects.equals(x.dbType(), dbType)).findFirst().orElse(null);
	}

	public static BizTypeEnum getByCode(int code) {
		return Arrays.asList(BizTypeEnum.values()).stream().filter(x -> Objects.equals(x.code(), code)).findFirst().orElse(null);
	}

}
